﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GraphViewer.View
{
    public partial class FormSearch : Form
    {
        public FormSearch()
        {
            InitializeComponent();
        }

        public string TextToSearch
        {
            get { return txtText.Text; }
        }

        public bool IsControlMSearch
        {
            get { return rdlCTM.Checked; }
        }

        private void FormSearch_Load(object sender, EventArgs e)
        {
            this.txtText.Focus();
            rdlCTM.Checked = true;
        }

        private void FormSearch_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Escape)
            {
                this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                this.Close();
            }
            else if (e.KeyData == Keys.Enter)
            {
                this.DialogResult = string.IsNullOrEmpty(this.TextToSearch) ? System.Windows.Forms.DialogResult.Cancel : System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            else if (e.KeyData == Keys.Left)
            {
                rdlCTM.Checked = true;
            }
            else if (e.KeyData == Keys.Right)
            {
                rdlRisco.Checked = true;
            }
        }

        private void btnFind_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }
    }
}
